﻿#ifndef WIDGETROIUNION_H
#define WIDGETROIUNION_H

#include <QWidget>
#include <QListView>
#include <QComboBox>
#include <QPushButton>
#include <QStandardItemModel>
#include "GraphicsView.h"
#include "WidgetRoiList.h"
#include "WidgetRoiDraw.h"

enum RegionAction{
    RA_Add = 0,
    RA_Sub
};
Q_DECLARE_METATYPE(RegionAction)

struct RoiItemData{
    ItemBase* item;
    RegionAction act;
};
Q_DECLARE_METATYPE(RoiItemData)

class WidgetRoiUnion : public QWidget
{
    Q_OBJECT
public:
    explicit WidgetRoiUnion(QWidget *parent = nullptr);

    void setImage(const QImage& img);
    QList<RoiItemData> getRoiList();
    GraphicsView* getView(){return mView->getView();}
signals:

private:
    void setupUI();
    void initConnection();
    void onRegionAdd();
    void onRegionRemove();
    void onRegionClear();

private:
    //control
    WidgetRoiList* lstvwRoi;
    WidgetRoiDraw* mView;
    QComboBox* cbboxRegionAction;

    QMetaObject::Connection polygonLinkUpdate;
    QMetaObject::Connection polygonLinkFinish;
    //var
    QImage mImg;
    QList<ItemBase*> mLstItem;

    QStandardItemModel* mModelROI;




};

#endif // WIDGETROIRESULT_H
